<html>
  <head>
    <title>Keyboard Shortcuts</title>
    <% watermark  = File.expand_path(File.join(Redcar.root, %w(plugins html_view views watermark-48.png))) %>
    <% redcar_css = File.expand_path(File.join(Redcar.root, %w(plugins html_view views default.css))) %>
    <link rel="stylesheet" href="file://<%= redcar_css %>" type="text/css" media="screen">
    <%= javascript_controller_actions %>
    <script type="text/javascript" src="file://<%= Redcar::HtmlView.jquery_path %>"></script>
    <script>
    function addKeyBinding(command) {
      var key = prompt("Key for " + command, "");
      Controller.addKeyBinding(key, command);
      window.location.href = "controller/index";
    }
  </script>
  </head>
  <body>
    <div id="top">
      <img src="file://<%=watermark%>" id="watermark"/>
      <h1>Keyboard Shortcuts</h1>
      <a href="controller/index">Refresh List</a>
    </div>
    <div class="main">
      <p><i>Click an action name to change the shortcut</i><p>
      <table>
        <tr>
          <th>Action</th>
          <th>Shortcut</th>
        </tr>
        <% i = 0 %>
        <% Redcar.app.main_keymap.map.sort_by{|key, command| clean_name(command)}.each do |key, command| %>
        <tr class="<%= i % 2 == 0 ? 'even':'odd'%>">
          <td><a href="javascript:addKeyBinding('<%=command %>');"><%= clean_name(command) %></a></td>
          <td><%= key %></td>
          <% i = i + 1%>
        </tr>
        <% end %>
      </table>
    </div>
  </body>
</html>